
;(function($){
	
$.fn.bgiframe = function(s) {

	if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
		s = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, s || {});
		var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
		               'style="display:block;position:absolute;z-index:-1;'+
			               (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
					       'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
					       'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
					       'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
					       'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
					'"/>';
		return this.each(function() {
			if ( $('> iframe.bgiframe', this).length == 0 )
				this.appendChild( document.createElement(html), this.firstChild );
		});
	}
	return this;
};

})(jQuery);


(function($) {
	
	var ajax = $.ajax;	
	var pendingRequests = {};	
	var synced = [];
	var syncedData = [];
	
	$.ajax = function(settings) {

		settings = jQuery.extend(settings, jQuery.extend({}, jQuery.ajaxSettings, settings));
		
		var port = settings.port;
		
		switch(settings.mode) {
		case "abort": 
			if ( pendingRequests[port] ) {
				pendingRequests[port].abort();
			}
			return pendingRequests[port] = ajax.apply(this, arguments);
		case "queue": 
			var _old = settings.complete;
			settings.complete = function(){
				if ( _old )
					_old.apply( this, arguments );
				jQuery([ajax]).dequeue("ajax" + port );;
			};
		
			jQuery([ ajax ]).queue("ajax" + port, function(){
				ajax( settings );
			});
			return;
		case "sync":
			var pos = synced.length;
	
			synced[ pos ] = {
				error: settings.error,
				success: settings.success,
				complete: settings.complete,
				done: false
			};
		
			syncedData[ pos ] = {
				error: [],
				success: [],
				complete: []
			};
		
			settings.error = function(){ syncedData[ pos ].error = arguments; };
			settings.success = function(){ syncedData[ pos ].success = arguments; };
			settings.complete = function(){
				syncedData[ pos ].complete = arguments;
				synced[ pos ].done = true;
		
				if ( pos == 0 || !synced[ pos-1 ] )
					for ( var i = pos; i < synced.length && synced[i].done; i++ ) {
						if ( synced[i].error ) synced[i].error.apply( jQuery, syncedData[i].error );
						if ( synced[i].success ) synced[i].success.apply( jQuery, syncedData[i].success );
						if ( synced[i].complete ) synced[i].complete.apply( jQuery, syncedData[i].complete );
		
						synced[i] = null;
						syncedData[i] = null;
					}
			};
		}
		return ajax.apply(this, arguments);
	};
	
})(jQuery);


var NFE = {
	keyCode: {
		ENTER: 13,
		ESC: 27,
		END: 35,
		HOME: 36,
		SHIFT: 16,
		TAB: 9,
		LEFT: 37,
		RIGHT: 39,
		UP: 38,
		DOWN: 40,
		DELETE: 46
	},
	ui:{sbar:true},
	frag:{}, 
	msg:{}, 
	loginUrl:"",
	jsonEval:function (json) {
		try{
			return eval('(' + json + ')');
		} catch (e){
			return {};
		}
	},
	ajaxError:function (xhr, ajaxOptions, thrownError){
		alert("Http status: "+xhr.status + " \najaxOptions: "+ ajaxOptions + " \nthrownError:"+thrownError);
	},
	ajaxDone:function (json){
		if(json.statusCode == 300) {
			if(json.message && alertMsg) alertMsg.error(json.message);
		} else if (json.statusCode == 301) {
			alertMsg.error(json.message, {okCall:function(){
				window.location = NFE.loginUrl;
			}});
		} else {
			if(json.message && alertMsg) alertMsg.correct(json.message);
		};
	}	
};

jQuery.extend(String.prototype, {
	isPositiveInteger:function(){
		return (new RegExp(/^[1-9]\d*$/).test(this));
	},
	isInteger:function(){
		return (new RegExp(/^\d+$/).test(this));
	},
	isNumber: function(value, element) {
		return (new RegExp(/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/).test(this));
	},
	trim:function(){
		return this.replace(/(^\s*)|(\s*$)|\r|\n/g, "");
	},
	trans:function() {
		return this.replace(/&lt;/g, '<').replace(/&gt;/g,'>').replace(/&quot;/g, '"');
	},
	replaceAll:function(os, ns) {
		return this.replace(new RegExp(os,"gm"),ns);
	},
	skipChar:function(ch) {
		if (!this || this.length===0) {return '';}
		if (this.charAt(0)===ch) {return this.substring(1).skipChar(ch);}
		return this;
	},
	isValidPwd:function() {
		return (new RegExp(/^([_]|[a-zA-Z0-9]){6,32}$/).test(this)); 
	},
	isValidMail:function(){
		return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(this.trim()));
	},
	isSpaces:function() {
		for(var i=0; i<this.length; i+=1) {
			var ch = this.charAt(i);
			if (ch!=' '&& ch!="\n" && ch!="\t" && ch!="\r") {return false;}
		}
		return true;
	},
	isPhone:function() {
		return (new RegExp(/(^([0-9]{3,4}[-])?\d{3,8}(-\d{1,6})?$)|(^\([0-9]{3,4}\)\d{3,8}(\(\d{1,6}\))?$)|(^\d{3,8}$)/).test(this));
	},
	isURL:function(){
		return (new RegExp(/^[a-zA-z]+:\/\/(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$/).test(this)); 
	}
});


(function($){
	$.fn.extend({

		loadUrl: function(url,data,callback){
		
			var $this = $(this);
			$.ajax({
				type:'POST',
				url:url,
				cache: false,
				data:data,
				success: function(html){
					var json = NFE.jsonEval(html);
					if (json.statusCode==301){
						alertMsg.error(NFE.msg["sessionTimout"], {okCall:function(){
							window.location = "/render.do?method=login";
						}});
					} if (json.statusCode==300){
						if (json.message) alertMsg.error(json.message);
					} else {
						$this.html(html).initUI();
						if ($.isFunction(callback)) callback();
					}
				},
				error: NFE.ajaxError
			});
		},
		initUI: function(){
			if($.isFunction(initUI))	
				initUI(this);
		},

		layoutH: function(content){
			var jBox = content || $("#container .tabsPageContent");
			var iTabsContentH = jBox.height();
			return this.each(function(){
				var iLayoutH = $(this).attr("layoutH") || 0;
				try {
					iLayoutH = parseInt(iLayoutH);
				} catch (e) {
					iLayoutH = 0
				}
				$(this).height(iTabsContentH - iLayoutH > 50 ? iTabsContentH - iLayoutH : 50);
			});
		},
		hoverClass: function(className){
			var _className = className || "hover";
			return this.each(function(){
				$(this).hover(function(){
					$(this).addClass(_className);
				},function(){
					$(this).removeClass(_className);
				});
			});
		},
		focusClass: function(className){
			var _className = className || "textInputFocus";
			return this.each(function(){
				$(this).focus(function(){
					$(this).addClass(_className);
				}).blur(function(){
					$(this).removeClass(_className);
				});
			});
		},
		inputAlert: function(){
			return this.each(function(){
				
				var $this = $(this);
				var altStr = $this.attr("alt");
				var isEmpty = function(){
					return (!$this.val() || $this.val() == altStr);
				}

				if (isEmpty()) $this.val(altStr).addClass("gray");
				$this.focus(function(){
					$this.removeClass("gray")
					if (isEmpty()) $this.val("");
				}).blur(function(){
					if (isEmpty()) $this.val(altStr).addClass("gray");
				});		
			});
		},
		isTag:function(tn) {
			if(!tn) return false;
			return $(this)[0].tagName.toLowerCase() == tn?true:false;
		},
		autoData:function(id,url,type){
			$.post(contextPath+url,"",function(data){
               getAutoComData(data,id,type);             
			});
		}
				
	});
	
	
})(jQuery);



(function($){
	$.fn.extend({

		tabs: function (options){
			var op = $.extend({reverse:false, eventType:"click", curentIndex:0, stTabHeader:"> .tabsHeader", stTab:">.tabsHeaderContent>ul", stTabPanel:"> .tabsContent", ajaxClass:"j-ajax", closeClass:"close", prevClass:"tabsLeft", nextClass:"tabsRight"}, options);
			var aTemp = {left:0, leftIndex:0};
			
			return this.each(function(){
				var jT = $(this);
				initTab(jT);
				$('.tabsContentBox').height(document.documentElement.clientHeight-138-54);
			});
			
			function initTab(jT){
				var jSelector = jT.add($("> *", jT));
				var jTabHeader = $(op.stTabHeader, jSelector);
				var jTabs = $(op.stTab + " li", jTabHeader);
				var jGroups = $(op.stTabPanel + " > *", jSelector);

				jTabs.unbind().find("a").unbind();
				jTabHeader.find("."+op.prevClass).unbind();
				jTabHeader.find("."+op.nextClass).unbind();
				
				jTabs.each(function(iTabIndex){
					if (op.curentIndex == iTabIndex) $(this).addClass("selected");
					else $(this).removeClass("selected");
					
					if (op.eventType == "hover") $(this).hover(function(event){switchTab(jT, iTabIndex)});
					else $(this).click(function(){switchTab(jT, iTabIndex)});

					$("a", this).each(function(){
						if ($(this).hasClass(op.ajaxClass)) {
							$(this).click(function(event){
								var jGroup = jGroups.eq(iTabIndex);
								if (this.href && !jGroup.html()) jGroup.loadUrl(this.href);
								if (op.eventType == "click") switchTab(jT, iTabIndex);
								return false;
							});
						} else if ($(this).hasClass(op.closeClass)) {
							$(this).click(function(event){
								jTabs.eq(iTabIndex).remove();
								jGroups.eq(iTabIndex).remove();
								if (iTabIndex == op.curentIndex) {
									op.curentIndex = (iTabIndex+1 < jTabs.size()) ? iTabIndex : iTabIndex - 1;
								} else if (iTabIndex < op.curentIndex){
									op.curentIndex = iTabIndex;
								}
								initTab(jT);
								return false;
							});
						}
					});
				});
				
				jGroups.hide().each(function(iGroupIndex){
					if (op.curentIndex == iGroupIndex) $(this).show();
				});

			}
			
			function switchTab(jT, iTabIndex){
				var jSelector = jT.add($("> *", jT));
				var jTabHeader = $(op.stTabHeader, jSelector);
				var jTabs = $(op.stTab + " li", jTabHeader);
				var jGroups = $(op.stTabPanel + " > *", jSelector);
				
				var jTab = jTabs.eq(iTabIndex);
				if (op.reverse && (jTab.hasClass("selected") )) {										
					jTabs.removeClass("selected");
					jGroups.hide();
				} else {
							
					op.curentIndex = iTabIndex;
					jTabs.removeClass("selected");
					jTab.addClass("selected");
					jGroups.hide().each(function(iGroupIndex){
						if (op.curentIndex == iGroupIndex) $(this).show();
					});
					if(typeof(switchTabBack)=="function"){
						switchTabBack();
					}
				}
			}
			
		}
	});
})(jQuery);





var navTab = {
	componentBox: null,
	_tabBox: null,
	_prevBut: null,
	_nextBut: null,
	_panelBox: null,
	_moreBut:null,
	_moreBox:null,
	_currentIndex: 0,
	
	_op: {id:"navTab", stTabBox:".navTab-tab", stPanelBox:".navTab-panel", mainTabId:"main", closeClass:"close", prevClass:"tabsLeft", nextClass:"tabsRight", stMore:".tabsMore", stMoreLi:"ul.tabsMoreList"},
	
	init: function(options){
		var $this = this;
		$.extend(this._op, options);

		this.componentBox = $("#"+this._op.id);
		this._tabBox = this.componentBox.find(this._op.stTabBox);
		this._panelBox = this.componentBox.find(this._op.stPanelBox);
		this._prevBut = this.componentBox.find("."+this._op.prevClass);
		this._nextBut = this.componentBox.find("."+this._op.nextClass);
		this._moreBut = this.componentBox.find(this._op.stMore);
		this._moreBox = this.componentBox.find(this._op.stMoreLi);

		this._prevBut.click(function(event) {$this._scrollPrev()});
		this._nextBut.click(function(event) {$this._scrollNext()});
		this._moreBut.click(function(){
			$this._moreBox.show();
			return false;
		});
		$(document).click(function(){$this._moreBox.hide()});
		this._init();
		this._ctrlScrollBut();
	},
	_init: function(){
		var $this = this;
		this._getTabs().each(function(iTabIndex){
			$(this).unbind("click").click(function(event){
				$this._switchTab(iTabIndex);
			});
			$(this).find("a."+navTab._op.closeClass).unbind("click").click(function(){
				if(typeof(navTabCloseCallBack)=="function"){
					if(!navTabCloseCallBack()){return false;}
				}
				$this._closeTab(iTabIndex);
			});
		});
		this._getMoreLi().each(function(iTabIndex){
			$(this).find(">a").unbind("click").click(function(event){
				$this._switchTab(iTabIndex);
			});
		});
		this._switchTab(this._currentIndex);
	},

	_getTabs: function(){
		return this._tabBox.find("> li");
	},
	_getPanels: function(){
		return this._panelBox.find("> div");
	},
	_getMoreLi: function(){
		return this._moreBox.find("> li");
	},
	_getTab: function(tabid){
		var index = this._indexTabId(tabid);
		return this._getTabs().eq(index);
	},
	_getPanel: function(tabid){
		var index = this._indexTabId(tabid);
		return this._getPanels().eq(index);
	},
	_getTabsW: function(iStart, iEnd){
		return this._tabsW(this._getTabs().slice(iStart, iEnd));
	},
	_tabsW:function(jTabs){
		var iW = 0;
		jTabs.each(function(){
			iW += $(this).outerWidth(true);
		});
		return iW;
	},
	_indexTabId: function(tabid){
		if (!tabid) return -1;
		var iOpenIndex = -1;
		this._getTabs().each(function(index){
			if ($(this).attr("tabid") == tabid){iOpenIndex = index; return;}
		});
		return iOpenIndex;
	},
	_getLeft: function(){
		return this._tabBox.position().left;
	},
	_getScrollBarW: function(){
		return this.componentBox.width()-55;
	},
	
	_visibleStart: function(){
		var iLeft = this._getLeft(), iW = 0;
		var jTabs = this._getTabs();
		for (var i=0; i<jTabs.size(); i++){
			if (iW + iLeft >= 0) return i;
			iW += jTabs.eq(i).outerWidth(true);
		}
		return 0;
	},
	_visibleEnd: function(){
		var iLeft = this._getLeft(), iW = 0;
		var jTabs = this._getTabs();
		for (var i=0; i<jTabs.size(); i++){
			iW += jTabs.eq(i).outerWidth(true);
			if (iW + iLeft > this._getScrollBarW()) return i;
		}
		return jTabs.size();
	},
	_scrollPrev: function(){
		var iStart = this._visibleStart();
		if (iStart > 0){
			this._scrollTab(-this._getTabsW(0, iStart-1));
		}
	},
	_scrollNext: function(){
		var iEnd = this._visibleEnd();
		if (iEnd < this._getTabs().size()){
			this._scrollTab(-this._getTabsW(0, iEnd+1) + this._getScrollBarW());
		}	
	},
	_scrollTab: function(iLeft, isNext){
		var $this = this;
		this._tabBox.animate({ left: iLeft+'px' }, 200, function(){$this._ctrlScrollBut();});
	},
	_scrollCurrent: function(){ // auto scroll current tab
		var iW = this._tabsW(this._getTabs());
		if (iW <= this._getScrollBarW()){
			this._scrollTab(0);
		} else if (this._getLeft() < this._getScrollBarW() - iW){
			this._scrollTab(this._getScrollBarW()-iW);
		} else if (this._currentIndex < this._visibleStart()) {
			this._scrollTab(-this._getTabsW(0, this._currentIndex));
		} else if (this._currentIndex >= this._visibleEnd()) {
			this._scrollTab(this._getScrollBarW() - this._getTabs().eq(this._currentIndex).outerWidth(true) - this._getTabsW(0, this._currentIndex));
		}
	},
	_ctrlScrollBut: function(){
		var iW = this._tabsW(this._getTabs());
		if (this._getScrollBarW() > iW){
			this._prevBut.hide();
			this._nextBut.hide();
			this._tabBox.parent().removeClass("tabsPageHeaderMargin");
		} else {
			this._prevBut.show().removeClass("tabsLeftDisabled");
			this._nextBut.show().removeClass("tabsRightDisabled");
			this._tabBox.parent().addClass("tabsPageHeaderMargin");
			if (this._getLeft() >= 0){
				this._prevBut.addClass("tabsLeftDisabled");
			} else if (this._getLeft() <= this._getScrollBarW() - iW) {
				this._nextBut.addClass("tabsRightDisabled");
			} 
		}
	},
	
	_switchTab: function(iTabIndex){
		var jTabs = this._getTabs();
		this._currentIndex = iTabIndex;
		jTabs.removeClass("selected").eq(iTabIndex).addClass("selected");
		this._getPanels().hide().eq(iTabIndex).show();
		this._scrollCurrent();
		
		this._getMoreLi().removeClass("selected").eq(iTabIndex).addClass("selected");
		
		this._reload(jTabs.eq(iTabIndex));
	},
			
	_closeTab: function(index){
		this._getTabs().eq(index).remove();
		this._getPanels().eq(index).remove();
		this._getMoreLi().eq(index).remove();
		if (this._currentIndex >= index) this._currentIndex--;
		this._init();
		this._scrollCurrent();
		this._reload(this._getTabs().eq(this._currentIndex));
	},
	closeTab: function(tabid){
		var index = this._indexTabId(tabid);
		if (index > 0) { this._closeTab(index); }
	},
	closeCurrentTab: function(){
		if (this._currentIndex > 0) {this._closeTab(this._currentIndex);}
	},
	closeAllTab: function(){
		this._getTabs().filter(":gt(0)").remove();
		this._getPanels().filter(":gt(0)").remove();
		this._getMoreLi().filter(":gt(0)").remove();
		this._currentIndex = 0;
		this._init();
		this._scrollCurrent();
	},
	_closeOtherTab: function(index){
		index = index || this._currentIndex;
		if (index > 0) {
			var str$ = ":eq("+index+")"
			this._getTabs().not(str$).filter(":gt(0)").remove();
			this._getPanels().not(str$).filter(":gt(0)").remove();
			this._getMoreLi().not(str$).filter(":gt(0)").remove();
			this._currentIndex = 1;
			this._init();
			this._scrollCurrent();
		} else {
			this.closeAllTab();
		}
	},

	_reload: function($tab){
		var flag = $tab.data("reloadFlag");
		var url = $tab.data("url");
		if (flag && url) {
			$tab.data("reloadFlag", null);
			$panel = this._getPanel($tab.data("tabid"));
			$panel.loadUrl(url, {}, function(){
				$panel.find("[layoutH]").layoutH();
			});
		}
	},
	reload_currentTab: function(){
		var $tab = this._getTabs().eq(this._currentIndex);
		var url = $tab.data("url");
		if (url) {
			$tab.data("reloadFlag", null);
			$panel = this._getPanel($tab.data("tabid"));
			$panel.loadUrl(url, {}, function(){
				$panel.find("[layoutH]").layoutH();
			});
		}
	},	
	reloadFlag: function(tabid){
		this._getTab(tabid).data("reloadFlag", 1);
	},
	reload: function(url, data, tabid){
		var $panel =  tabid ? this._getPanel(tabid) : this._getPanels().eq(this._currentIndex);
		
		if (!url) {
			$tab = tabid ? this._getTab(tabid) : this._getTabs().eq(this._currentIndex);
			url = $tab.data("url");
		}
		if (url) {
			$panel.loadUrl(url, data, function(){
				$panel.find("[layoutH]").layoutH();
			});
		}
	},
	getCurrentPanel: function() {
		return this._getPanels().eq(this._currentIndex);
	},
	reloadMoreLi:function(index,title){
		this._getMoreLi().eq(index).find('a').attr('title',title).text(title);
		this._init();
		return false;
	},
	openTab: function(tabid, url, title){
		
		var iOpenIndex = this._indexTabId(tabid);

		if (iOpenIndex >= 0){
			var jTab = this._getTabs().eq(iOpenIndex);
			var stSpan = jTab.attr("tabid") == this._op.mainTabId ? "> a > span > span" : "> a > span";
			jTab.find(stSpan).text(title);
			var jPanel = this._getPanels().eq(iOpenIndex);
			/*new abank*/
			jPanel.html("");
			jPanel.loadUrl(url, {}, function(){
				jPanel.find("[layoutH]").layoutH();
			});
			this._currentIndex = iOpenIndex;
			this.reloadMoreLi(iOpenIndex,title);
		} else {
			var tabFrag = '<li tabid="#tabid#"><a href="javascript:" title="#title#"><span>#title#</span></a><a href="#" class="close">close</a></li>';
			this._tabBox.append(tabFrag.replace("#tabid#", tabid).replaceAll("#title#", title));
			this._panelBox.append('<div class="openTabBox"></div>');
			var c_h = document.documentElement.clientHeight-138-25;
			$('.openTabBox').height(c_h);
			this._moreBox.append('<li><a href="javascript:" title="#title#">#title#</a></li>'.replaceAll("#title#", title));
			
			var jTabs = this._getTabs();
			var jPanel = this._getPanels().filter(":last");
			jPanel.loadUrl(url, {}, function(){
				jPanel.find("[layoutH]").layoutH();
			});
			this._currentIndex = jTabs.size() - 1;
						
		}
		
		this._init();
		this._scrollCurrent();		
		this._getTabs().eq(this._currentIndex).data("url", url).data("tabid", tabid);
	}
};

function target_init(){
	$("a[target=navTab]").each(function(){
		$(this).unbind().click(function(event){
			var $this = $(this);
			var title = $this.attr("title") || $this.text();
			var rel = $this.attr("rel") || "_blank";
			navTab.openTab(rel, $this.attr("href"), title);
			event.preventDefault();
		});
	});			
}


;(function($){
	$.ajaxLayer = {
		_op:{'dataType':'json'},
        open:function(options){
			var op = $.extend(this._op,options);			
			var openner=$("#"+op.id);
			if(!$('#ajaxLayer-box').length>0){
				var html = new String;				
				  html += "<div id='ajaxLayer-box' class='ajaxLayer-box'><div id='ajaxLayer-content'></div>";
				  //html += "<span class='ajaxLayer-close' id='ajaxLayer-close'></span>";		 
				  html += "</div>";		  		 	 
				  $('body').append(html);
			}
		    var box = $('#ajaxLayer-box');	
		    box.show();
		    var content = $("#ajaxLayer-content");
		    try{
		    	//content.get(0).innerHTML=op.data;
		    	content.html(op.data);
		    }catch(e){		    	
		    	alertMsg.info(e.message);
		    }finally{
		    	
		    }
		    this.getPosition(openner,box,content);
		    if(op.dataType=="json"||op.dataType=="url"){
		    	this.li_event(openner,box,content);
		    }
		    if(op.dataType=="page"){
		    	this.check_event(openner);
		    }
		    if(op.dataType=="mutiCheck"||op.dataType=="mPage"){
		    	this.mutiCheck_event(op);
		    }
		    if(op.dataType="time"){
		    	this.time_event(openner, box);
		    }
		    this.add_event(openner,box,content,op);
		    this.esc_event(openner);
		    this.box_event(openner,box);
		    if(typeof(unbindBox)=="function"){
		    	unbindBox();
		    }
		},
		getPosition:function(openner,box,content){
			var offset = openner.offset();
			var maxLeft = $(window).width()-box.width();
			var left = offset.left;
			if(left>maxLeft){
				  var left=maxLeft-40;
			  }
			box.css({
			  top:offset.top+openner.height()-2,
			  left:left
		    });
		},
		li_event:function(openner,box,content){
			$('#ajaxLayer-close').hide();
			var $li = $('li',box);
			if($li.length>0){
				$li.hoverClass('li-hover');
				  $li.each(function(){
					  $(this).click(function(){
						  var text = $(this).text();
						  var key = $(this)[0].getAttribute("key");
						  openner.val(text);					  
						  openner.attr('key',key);
						  if(typeof(ajaxLayerBack)=="function"){
							  ajaxLayerBack();
						  }
						  box.hide();
					  });
				  });		 			
			}
		},
		check_event:function(openner){
			this.auto_height();
			this.ajaxLayer_check();
			$('#ajaxLayer-sub').unbind().bind("click",function(){
				  var key="";
				  var value="";
			      $('#ajaxLayer-box .list tr').each(function(){
				      if($(this).hasClass('ajaxLayer-checked')){
				        key = $(this).find('td').eq(0).text();
					    value = $(this).find('td').eq(1).text();
					    return;
				      }
			      });
			      openner.val(value);
				  openner.attr("key",key);
				  $.ajaxLayer.close();
				  if(typeof(ajaxCheckBack)=="function"){
						ajaxCheckBack();
				  }
			      return false;
		    });
		},
		mutiCheck_event:function(op){
			this.auto_height();
			this.muti_check();
			$('#muti_sub').unbind().bind("click",function(){
		    	  var key="",value="";
			      $('#muti_check_table tr').each(function(i){
				      if($(this).hasClass('ajaxLayer-checked')){
				      key = key+$(this).find('td').eq(0).text()+",";
					  value = value +$(this).find('td').eq(1).text()+",";					  
				  }
			  });
			      $("#"+op.id).val(value);
				  $("#"+op.id).attr("key",key);
				  $.ajaxLayer.close();
			      return false;
		  });
		},
		time_event:function(openner,box){
			$('#time-sub',box).unbind().click(function(){
				var select = $('select',$('#ajax-time'));
				var array = new Array();
				select.each(function(){
					array.push($('option:selected',$(this)).text());
				});
				try{
					var x = "-";
					var y = ":";
					var z = " ";
                    if(array[0]==""||array[1]==""){x="";z="";}
                    if(array[2]==""||array[3]==""){y="";z="";}
					openner.val(array[0]+x+array[1]+z+array[2]+y+array[3]);

				}catch(e){
					alertMsg.info(e.message);
				}finally{
					$.ajaxLayer.close();		
						}				
			});
		},
		add_event:function(openner,box,content,op){						  
		    $('#clear_'+op.id).unbind().bind("click",function(){
		    	$.ajaxLayer.clear_key(openner);
		    });
	        //$('#ajaxLayer-close').unbind().click(function(){
	        	//$.ajaxLayer._close(box);
	        //});
		},
		close:function(){
			$('#ajaxLayer-box').hide();
		},
		_close:function(box){
			box.hide();
		},
		clear_key:function(openner){
			openner.attr("key","");
			openner.val("");
		},
		esc_event:function(openner){
			openner.keyup(function(event){
				var keyCode = event.keyCode;
				  if(keyCode==27){
					  $.ajaxLayer.close();
				  }
			});
		},
		box_event:function(openner,box){
			var offset = box.offset();
			$('body').unbind().mousemove(function(e){
				var x = offset.left+box.width();
				var y = offset.top+box.height();
				if(!((e.pageX>(offset.left-100)&&e.pageX<(x+100))&&(e.pageY>(offset.top-100)&&e.pageY<(y+100)))){
					$.ajaxLayer.close();
				}
			});
		},
		auto_height:function(){
			if($('#pageSize2').length<0){
				return;
			}
			 var count = $('#pageSize2').val();
			 $('.ajaxLayer-page').livequery(function(){
				 $(this).height(count*22+22+27+40);
			 });
		},
		ajaxLayer_check:function(){
			var $tr = $('#one_check tbody tr');
			if(!$tr.length>0){
				//alertMsg.info("无初始数据!");
				return;
			}
	          $tr.each(function(){	        	  	  
	    		  $(this).unbind().click(function(){
	    			  $(this).siblings().removeClass().addClass("ajaxLayer-check").css("background","#fff");
	    			  $(this).removeClass().addClass("ajaxLayer-checked").css("background","#dedede");
	    		  }).hoverClass("hover");
	          });
		},
		muti_check:function(){
			var $tr = $('#muti_check_table tbody tr');
			if(!$tr.length>0){
				//alertMsg.info("无初始数据!");
				return;
			}
	          $tr.each(function(){
	        	  $(this).hoverClass('hover');		  
	    		  $(this).unbind().toggle(function(){
	    			  $(this).css('background','#dedede');
	    			  $(this).removeClass('ajaxLayer-check').addClass('ajaxLayer-checked');
	    		  },function(){
	    			  $(this).css('background','#ffffff');
	    			  $(this).removeClass('ajaxLayer-checked').addClass('ajaxLayer-check');
	    		  });
	          });
		}
	};
})(jQuery);

function getAutoComData(data,id,type){

	var array=[];
	var temp_array = eval(data);				  
	  for(i=0;i<temp_array.length;i++){
          array.push(temp_array[i].value);
		}
	  if(type=="multiple"){	
		  $(id).autocomplete(array,{
			  multiple:true,
			  dataType:'json'
		  }).result(function(e,item){
			  if(typeof(autoBack)=="function"){
				  autoBack(item); 
			  }
		  });
	  }else{
		  $(id).autocomplete(array).result(function(e,item){
				 if(typeof(autoBack)=="function"){
					  autoBack(item); 
				  }
			 });
	  }
	 
}